/**
 * Definition for a binary tree node.
 * public class TreeNode {
 *     int val;
 *     TreeNode left;
 *     TreeNode right;
 *     TreeNode(int x) { val = x; }
 * }
 */
class Solution {
    public boolean isSymmetric(TreeNode root) {
        if(null == root) {
            return true;
        }
        return isSymmetricChild(root.left,root.right);
    }
     private boolean isSymmetricChild(TreeNode leftTree,TreeNode rightTree) {
        if(null != leftTree && null == rightTree || null != rightTree && null == leftTree) {
            return false;
        }
        if(null == leftTree && rightTree == null) {
            return true;
        }
        if(leftTree.val != rightTree.val) {
            return false;
        }
        return isSymmetricChild(leftTree.right,rightTree.left) && isSymmetricChild(leftTree.left,rightTree.right);
    }
}